package com.lixianhe.onlineexam.controller;


import com.lixianhe.onlineexam.pojo.MultiQuestion;
import com.lixianhe.onlineexam.service.MultiQuestionService;
import com.lixianhe.onlineexam.util.ApiResultHandler;
import com.lixianhe.onlineexam.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MultiQuestionController {
    @Autowired
    private MultiQuestionService multiQuestionService;

    @PostMapping("MultiQuestion")
    public R MultiQuestion(@RequestBody MultiQuestion multiQuestion) {
        int res = multiQuestionService.addMultiQuestion(multiQuestion);
        if (res == 1) return ApiResultHandler.buildApiResult(200, "添加成功", res);
        return ApiResultHandler.buildApiResult(400, "添加失败", res);
    }

    @GetMapping("multiQuestionId")
    public R multiQuestionId() {
        MultiQuestion multiQuestion = multiQuestionService.multiQuestionId();
        return ApiResultHandler.buildApiResult(200, "查询选择题Id", multiQuestion);
    }
}
